Re: [GENERAL] ALTER TABLE

Поиск
Список
Период
Сортировка
От Stuart Rison
Тема Re: [GENERAL] ALTER TABLE
Дата
Msg-id v04020a00b3d4bf066bee@[128.40.242.190]
обсуждение исходный текст
Ответ на ALTER TABLE  ("Jonathan R. Karlen" <jkarlen@karlen.com>)
Список pgsql-general
Hi,

To the best of my knowledge, still no way of droping a field directly by
using ALTER.

Usual trick is to do something like:

SELECT <fields>,<you>,<want>,<to>,<keep>
INTO temp_table
FROM <table_you_want_to_alter>;

DROP TABLE <table_you_want_to_alter>;
ALTER TABLE temp_table RENAME TO <table_you_want_to_alter>;

But bear in my that:

- this will not preserve oid's...
- I think things like RULES and TRIGGERS on that table will be affected
(i.e. not work) since these use the table OID and will have to be
regenerated
- constraints, indices, primary keys etc. will be lost and have to be
regenerated

HTH,

Stuart

>Greetings,
>
>Is there a way to drop a field from a table?  ALTER TABLE seems to only
>allow the adding and modification of fields.
>
>Thanks.
>
>Jonathan Karlen
>**********************************************************
>Jonathan R. Karlen
>Karlen Internet Solutions
>jkarlen@karlen.com
>http://www.karlen.com

+--------------------------+--------------------------------------+
| Stuart C. G. Rison       | Ludwig Institute for Cancer Research |
+--------------------------+ 91 Riding House Street               |
| N.B. new phone code!!    | London, W1P 8BT                      |
| Tel. +44 (0)207 878 4041 | UNITED KINGDOM                       |
| Fax. +44 (0)207 878 4040 | stuart@ludwig.ucl.ac.uk              |
+--------------------------+--------------------------------------+

В списке pgsql-general по дате отправления:

Предыдущее
От: "Jonathan R. Karlen"
Дата:
Сообщение: ALTER TABLE
Следующее
От: "Hub.Org News Admin"
Дата:
Сообщение: ...